﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Media;

namespace GeometryViz3D.Model
{
    public class G3DColors
    {
        static string[] m_colors = new string[]
        {
            "Black",
            "Blue",
            "Brown",
            "Cyan",
            "Gray",
            "Green",
            "Magenta",
            "Orange",
            "Pink",
            "Purple",
            "Red",
            "Yellow"
        };

        static Dictionary<string, string> m_colorTable = new Dictionary<string, string>()
        {
            {"#FF000000", "Black"},
            {"#FF0000FF", "Blue"},
            {"#FFA52A2A", "Brown"},
            {"#FF00FFFF", "Cyan"},
            {"#FF808080", "Gray"},
            {"#FF008000", "Green"},
            {"#FFFF00FF", "Magenta"},
            {"#FFFFA500", "Orange"},
            {"#FFFFC0CB", "Pink"},
            {"#FF800080", "Purple"},
            {"#FFFF0000", "Red"},
            {"#FFFFFF00", "Yellow"}
        };

        public static string[] Colors
        {
            get { return m_colors; }
        }

        public static string GetColorName(string hexValue)
        {
            if (m_colorTable.ContainsKey(hexValue))
            {
                return m_colorTable[hexValue];
            }
            else
            {
                return "Black";
            }
        }

        public static Color GetColor(string colorName)
        {
            Color c = System.Windows.Media.Colors.Black;

            if (!string.IsNullOrEmpty(colorName))
            {
                c = (Color)ColorConverter.ConvertFromString(colorName);
            }

            return c;
        }
    }
}
